//导入 percent 函数
let {percent} = require('./percent');
let r = require('./rand');
let axios = require('axios');

//获取按钮
let btns = document.querySelectorAll('button');

//测试 percent
btns[0].onclick = function(){
    //调用函数
    if(percent(60)){
        alert('恭喜啊~~~ 恭喜 奖品为 小米音响一枚~')
    }else{
        alert('再接再厉~~再创辉煌~~')
    }
}

//点击切换背景颜色
btns[1].onclick = function(){
    //修改颜色
    document.body.style.background = `rgb(${r(150, 255)},${r(150, 255)}, ${r(150, 255)})`
}

//发送请求
btns[2].onclick = async function(){
    let {data} = await axios.get('http://api.xiaohigh.com/duanzi')
    console.log(data);
}
